<template>
  <hierTree :data="data" v-bind="attrs" :ref="ref"
    @select="select"
    @contextmenu="contextmenu"
    @add="add"
    @remove="remove"
    @menu="menu"></hierTree>
</template>

<script>
const ref='navTree';
export default {
  name:ref,
  components: {},
  inject:['anc'],
  data() {
    return {
      ref,
    };
  },
  props: {
    data:{
        default:()=>{
            return [];
        }
    }
  },
  watch: {},
  computed: {
    attrs(){
        return {
            title:{
                "en-US":'AAA',
                "zh-CN": 'AAA'
            }[this.G_Locale],
            rootId:'root',
            nameId:'id',
            namePid:'parentId',
            nameTitle:'title',
            rootEnable:false,
            // menuEnable:this.anc.dataSet.currentClass.id==='consume'?false:true,
            menuEnable:true,
            addEnable:false,
            removeEnable:true,
            menus:[
                // {
                //     title:{
                //         "en-US":'add1',
                //         "zh-CN": '添加1'
                //     }[this.G_Locale],
                //     disabled:false,
                //     menuStyle:{color:'red'}
                // }
            ]
        }
    },
  },
  created() {},
  mounted() {
    this.$nextTick(()=>{
      this.$set(this.anc.vms,this.ref, this);
      this.select(this.data[0])
      this.setTree(tree=>{
          tree.handleSelect(0)
      })
    })
  },
  methods: {
    select(item,data){
      this.anc.navSelect(item)
    },
    contextmenu(item,e,position){

    },
    add(item){

    },
    remove(item){
      this.anc.closeTrace(item)
    },
    menu(menu,item){
        
    },
    setTree(fn){
      this.$children[0].setTree(fn)
    },
    handleSelect(nodeKey){
      this.$children[0]. handleSelect(nodeKey)
    },
    findTreeNode(key,value){
      return this.$children[0].findTreeNode(key,value)
    }
  }
};
</script>
<style scoped>
</style>